<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link href="/resource/css/bootstrap.css" rel="stylesheet">
    <script type="text/javascript" src="/resource/js/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="/resource/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
<h4>配件维修单</h4>
    <form:form action="add" modelAttribute="weiXiu" enctype="multipart/form-data" method="post">
        <table class="table">
            <tr>
                <td>联络单号:</td>
                <td><form:input path="danhao"></form:input>
                 </td>
                <td></td>
                <td>报送日期</td>
                <td><form:input path="bstime" onclick="WdatePicker()"></form:input></td>
            </tr>
            <tr>
                <td>制造部:</td>
                <td><form:input path="zhizaobu"></form:input></td>
                <td></td>
                <td>制造部编号:</td>
                <td><form:input path="zhizaobuid"></form:input></td>
            </tr>
            <tr>
                <td>配件:</td>
                <td><form:select path="peijianid" id="pj"></form:select></td>
                <td></td>
                <td>金额:</td>
                <td><form:input path="money"></form:input></td>
            </tr>
            <tr>
                <td>加工检验图片上传</td>
                <td><form:input path="picurl" id="picurl"></form:input>
                </td>
                <td><input type="file"  onchange="upFile(this)"></td>
            </tr>
            <tr>
                <td>采购人:</td>
                <td><form:input path="caigouren"></form:input></td>
                <td></td>
                <td>报销人:</td>
                <td><form:input path="baoxiaoren"></form:input></td>
            </tr>
            <tr>
                <td>备注:</td>
                <td><form:textarea path="beizhu"></form:textarea></td>
            </tr>
            <tr>
                <td colspan="5">
                    <input type="submit" value="提交">
                </td>
            </tr>
        </table>
    </form:form>

<script>
    $(function(){
        $.ajax({
            type:"post",
            data:{},
            url:"selectPeijian",
            success:function(msg){
                $("#pj").val('');
                $("#pj").append("<option value=''>请选择</option>")
                for(var i in msg){
                    $("#pj").append("<option value='"+msg[i].peijianid+"'>"+msg[i].peijianid+"-"+msg[i].pjname+"</option>");
                }
            }
        })
    });
    function upFile(obj){
        var formdata=new FormData();
        formdata.append("file",obj.files[0]);
        $.ajax({
            type:"post",
            data:formdata,
            url:"getFile",
            contentType:false,
            processData:false,
            success:function(msg){

                $("#picurl").val(msg);
            }
        })
    }
</script>
</body>


</html>